home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
DATABASE
/
NFLTPW11.ZIP
/
NFLTPW.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-07-12
|
42KB
|
1,361 lines
Program NFLTPW;
{$r nfltpw.res}
uses WinTypes, WinProcs, WObjects, Printer,
win31,bitmap,Strings,stddlgs;
const
MaxTeams = 28;
MaxGames = 14;
MaxWeeks = 18;
PlayerNameSize = 20;
ScoreFieldSize = 3;
TeamNameSize = 25;
DLLName = 'NFLLIB.DLL';
em_DLLNotFound = 1;
cm_PlayerMaint = 102;
cm_DeletePlayers = 103;
cm_DeleteSchedule = 104;
cm_EnterSchedule = 105;
cm_EnterPicks = 202;
cm_EnterScores = 203;
cm_PrintSchedule = 301;
cm_PrintResults = 302;
cm_SetupPrinter = 303;
cm_about = 401;
id_AddPlayer = 102;
id_DeletePlayer = 103;
id_BoxMask = 100;
id_ButtonMask = 100;
id_TeamMask = 200;
id_week = 11;
id_PlayerCombo = 12;
id_PickPoints = 13;
id_PlayerBox = 101;
id_Transparent = 10;
type
pMyDialog = ^tMyDialog;
tmyDialog = object(tDialog)
constructor init(aParent:pWindowsObject; aName:pChar);
procedure wmCtlColor(var Msg:tMessage);
virtual wm_first + wm_CtlColor;
end;
PickType = (Visitor,Home,None);
tNFLApp = object(tApplication)
Lib: THandle;
constructor Init(AName: PChar);
destructor done; virtual;
procedure InitMainWindow; virtual;
procedure WritePlayerList; virtual;
end;
pMyListBox = ^tMyListBox;
tmyListBox = object(tlistbox)
procedure wmVScroll(var msg:tmessage); virtual wm_first + wm_VScroll;
end;
procedure tmylistbox.wmVScroll(var msg:tmessage);
begin
case msg.wparam of
sb_LineDown:
if GetSelIndex <> getcount then
begin
SetSelIndex(GetSelIndex + 1);
sendmessage(Parent^.hwindow,wm_command,getid,
hwindow or (lbn_selchange shl 16));
end;
sb_LineUp :
if GetSelIndex <> 0 then
begin
SetSelIndex(GetSelIndex - 1);
sendmessage(Parent^.hwindow,wm_command,getid,
hwindow or (lbn_selchange shl 16));
end;
else DefWndProc(msg);
end;
end;
var NFLApp : tNFLApp;
constructor tmydialog.init(aParent:pWindowsObject; aName:pChar);
begin
tdialog.init(aparent,aname);
end;
type
ListRec = record
ListStrings : pStrCollection;
ListSelection : integer;
end;
ComboRec = record
ComboStrings : pStrCollection;
ComboSelection : array[0..20] of Char;
end;
SchdTransferRec = record
STRWeek : ListRec;
STRTeams : array[1..MaxTeams] of ComboRec;
end;
TeamRec = record
Name : array[0..PlayerNameSize] of char;
Score : array[0..3] of char;
end;
Scores = record
Score : array [1..MaxGames,0..1] of byte;
end;
Schedule = record
Team : array [1..MaxGames,0..1] of byte;
GameScore : Scores
end;
PickData = record
GamePick : array [1..14] of word;
MNFScore : integer;
end;
ResultData = record
Wins,
Losses,
Ties,
PtDiff : word;
end;
Player = record
Name : pchar;
PickRec : array [1..MaxWeeks] of PickData;
Results : array [1..MaxWeeks] of ResultData;
end;
tPickRec = array [1..MaxWeeks] of PickData;
tResults = array [1..MaxWeeks] of ResultData;
pPlayer = ^tPlayer;
tPlayer = object(tObject)
Name : pchar;
PickRec : tPickRec;
Results : tResults;
constructor init(NewName : pchar;
NewPickRec : tPickRec;
NewResults : tResults);
constructor Load(var s:tstream);
procedure Store(var s:tstream); virtual;
destructor Done; virtual;
end;
tPlayerCollection = record
vs : pstringcollection;
focus : word;
end;
const
rPlayer : tstreamrec = (
objtype : 150;
vmtlink: ofs(typeof(tplayer)^);
load : @tplayer.load;
store: @tplayer.store);
constructor tPlayer.Init(NewName : pchar;
NewPickRec : tPickRec;
NewResults : tResults);
begin
tobject.init;
Name := NewName;
PickRec := NewPickRec;
Results := NewResults;
end;
constructor tplayer.load(var s:tstream);
begin
name := s.strread;
s.read(pickrec,sizeof(pickrec));
s.read(results,sizeof(results));
end;
procedure tplayer.store(var s:tstream);
begin
s.strwrite(Name);
s.write(PickRec,sizeof(PickRec));
s.write(Results,sizeof(Results));
end;
destructor tPlayer.done;
begin
StrDispose(Name);
tobject.done;
end;
type
pStandings = ^tStandings;
tStandings = object(tObject)
Wins,
Losses,
Ties,
PtDiff : word;
Name : pchar;
constructor init(NewName : pchar;
NewWins,
NewLosses,
NewTies,
NewPtDiff : word);
destructor Done; virtual;
end;
constructor tStandings.init(NewName : pchar;
NewWins,
NewLosses,
NewTies,
NewPtDiff : word);
begin
tobject.init;
Name := NewName;
Wins := newwins;
Losses := newlosses;
ties := newties;
PtDiff := newptdiff;
end;
destructor tStandings.done;
begin
tobject.done;
end;
type
pStandingsCollection = ^tStandingsCollection;
tStandingsCollection = object(tSortedCollection)
function KeyOf(Item:pointer): pointer; virtual;
function Compare(key1, key2: pointer):integer; virtual;
end;
function tStandingsCollection.KeyOf(item:pointer): pointer;
begin
KeyOf := pstandings(item);
end;
function tStandingsCollection.Compare(key1,key2:pointer):integer;
begin
if pstandings(key1)^.Wins < pstandings(key2)^.Wins
then compare := 1
else if pstandings(key1)^.Wins > pstandings(key2)^.Wins
then compare := -1
else if pstandings(key1)^.PtDiff > pstandings(key2)^.PtDiff
then compare := 1
else compare := -1;
end;
type
pSchedule = ^tSchedule;
tSchedule = object(tObject)
ScheduleRec : Schedule;
constructor init(NewSchedule : Schedule);
constructor load(var s:tBufStream);
procedure store(var s:tBufStream); virtual;
destructor done; virtual;
end;
pNumericEdit = ^tNumericEdit;
tNumericEdit = object(tEdit)
procedure wmchar(var Msg:tMessage);virtual Wm_first + wm_char;
end;
pSchDialog = ^tSchDialog;
tSchDialog = object(tMyDialog)
sWeek : pMyListBox;
combo : array [1..MaxTeams] of pcombobox;
constructor init(aParent:pWindowsObject; aName:pChar);
procedure setupwindow; virtual;
procedure StoreSched;
procedure Ok(var Msg: TMessage);
virtual id_First + id_ok;
procedure HandleListBox(var Msg:tMessage);
virtual id_first + id_Week;
end;
pScoreDialog = ^tScoreDialog;
tScoreDialog = object(tMyDialog)
scoreWeek : pMyListBox;
TeamName : array [1..MaxTeams] of pStatic;
ScoreEdit : array [1..MaxTeams] of pNumericEdit;
constructor init(aParent:pWindowsObject; aName:pChar);
procedure SetupWindow; virtual;
procedure BuildSchedule;
procedure StoreScores;
procedure Ok(var Msg: TMessage);
virtual id_First + id_ok;
procedure Han